package com.fhc;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

import com.vladimirjosu.util.Util;

public class Security implements Runnable {
	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer st;
	static Random rnd;

	void solve() throws IOException {
		int tests = nextInt();

		for (int test = 1; test <= tests; test++) {
			solveOne(test);
		}
	}

	private void solveOne(int test) throws IOException {
		int totalSections = nextInt();
		String kFirst = nextToken(), kSecond = nextToken();
		int n = kFirst.length();

		out.print("Case #" + test + ": ");

		String res = null;

		if (!checkPair(totalSections, kFirst, kSecond)) {
			res = "IMPOSSIBLE";
		} else {
			final char[] letters = { 'a', 'b', 'c', 'd', 'e', 'f' };

			StringBuilder sb = new StringBuilder();

			for (int i = 0; i < n; i++) {
				char c = kFirst.charAt(i);

				if (c == '?') {
					String before = sb.substring(0, i).toString();
					String after = kFirst.substring(i + 1);
					char resChar = Character.MAX_VALUE;

					search: for (char tryChar : letters) {
						String cur = before + tryChar + after;

						if (checkPair(totalSections, cur, kSecond)) {
							resChar = tryChar;
							break search;
						}
					}

					if (resChar == Character.MAX_VALUE) {
						throw new AssertionError();
					}

					sb.append(resChar);
				} else {
					sb.append(c);
				}
			}

			res = sb.toString();
		}

		out.println(res);
	}

	private boolean checkPair(int totalSections, String kFirst, String kSecond)
			throws IOException {
		if (kFirst.length() != kSecond.length()) {
			throw new AssertionError();
		}

		// out.println("Check: " + kFirst + " " + kSecond);

		int n = kFirst.length(), sectionSize = n / totalSections;

		String[] kFirstSections = getSections(n, sectionSize, kFirst), kSecondSections = getSections(
				n, sectionSize, kSecond);

		boolean[][] g = new boolean[totalSections][totalSections];

		for (int i = 0; i < totalSections; i++) {
			for (int j = 0; j < totalSections; j++) {
				g[i][j] = checkSections(kFirstSections[i], kSecondSections[j]);
			}
		}

		int[] mt = new int[totalSections];
		boolean[] used = new boolean[totalSections];

		Arrays.fill(mt, -1);

		for (int i = 0; i < totalSections; i++) {
			Arrays.fill(used, false);
			if (!dfs(i, totalSections, used, mt, g)) {
				return false;
			}
		}

		return true;
	}

	private boolean dfs(int u, int n, boolean[] used, int[] mt, boolean[][] g) {
		if (used[u]) {
			return false;
		}

		used[u] = true;

		for (int v = 0; v < n; v++) {
			if (g[u][v]) {
				if (mt[v] == -1 || dfs(mt[v], n, used, mt, g)) {
					mt[v] = u;
					return true;
				}
			}
		}

		return false;
	}

	private boolean checkSections(String a, String b) {
		if (a.length() != b.length()) {
			throw new AssertionError();
		}
		int n = a.length();
		for (int i = 0; i < n; i++) {
			char aChar = a.charAt(i), bChar = b.charAt(i);

			if (aChar == '?' || bChar == '?') {
				continue;
			} else if (aChar != bChar) {
				return false;
			}
		}
		return true;
	}

	private String[] getSections(int n, int m, String s) {
		if (n != s.length() || n % m != 0) {
			throw new AssertionError();
		}

		String[] res = new String[n / m];
		for (int i = 0, j = 0; i < n; i += m, ++j) {
			res[j] = s.substring(i, i + m);
		}
		return res;
	}

	public static void main(String[] args) {
		new Security().run();
	}

	public void run() {
		try {
			final String className = this.getClass().getName().toLowerCase();

			try {
				// in = new BufferedReader(new FileReader(className + ".in"));
				in = new BufferedReader(new InputStreamReader(
						Util.getInputStream("input.txt")));

				out = new PrintWriter(new FileWriter(className + ".out"));
				// in = new BufferedReader(new FileReader("input.txt"));
				// out = new PrintWriter(new FileWriter("output.txt"));
			} catch (FileNotFoundException e) {
				in = new BufferedReader(new InputStreamReader(System.in));
				out = new PrintWriter(System.out);
			}

			rnd = new Random();

			solve();

			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(42);
		}
	}

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			String line = in.readLine();

			if (line == null)
				return null;

			st = new StringTokenizer(line);
		}

		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}